﻿/*
 * 版 本 v1.0
 * Copyright (c) 2013-2018 广州市同慧信息科技有限公司
 * 创建人：ftquan
 * 日 期：2017.04.18
 * 描 述：查看模型计算结果
 */

var keyValue = request('modelId');
var warnId = request('warnId');
var companyId = request("companyId");
var kjnd = request("kjnd");
var kjkmCode = request("kjkmCode");
var wldxCode = request("wldxCode");


var userdefault = {};
var selectedRow;

var bootstrap = function ($, learun) {
    "use strict";

    var jfGrid1 = null;

    var page = {
        init: function () {
            page.bind();
            page.initData();
        },
        bind: function () {
            // 优化滚动条
            $('.lr-layout-wrap').lrscroll();
            $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
                // 调用后台查询
                // queryJson 查询条件
                page.search(queryJson);

            }, 200, 888);

            // 支付明细
            jfGrid1 = $('#pzGrid').jfGrid({
                headData: [
                    {label: '单位名称', name: 'companyName', width: 160, align: 'left'},
                    {label: '科目', name: 'kjkmCode', width: 160, align: 'left'},
                    {label: "会计年度", name: "kjnd", width: 60, align: "center"},
                    {label: "期间", name: "kjqj", width: 40, align: "center"},
                    {label: "凭证日期", name: "pzrq", width: 70, align: "center"},
                    {label: '凭证号', name: 'pzh', width: 60, align: 'center'},
                    {label: '摘要', name: 'zy', width: 250, align: 'left'},
                    {
                       label: '借', name: 'j', width: 110, align: 'right', statistics: true,
                       formatter: function (cellvalue) {
                           return $.formatMoney(cellvalue, 2)
                       }
                   },
                   {label: '贷', name: 'd', width: 110, align: 'right', statistics: true,
                       formatter: function (cellvalue) {
                           return $.formatMoney(cellvalue, 2)
                       }
                    },
//                    {label: '制单人', name: 'zdy', width: 90, align: 'center'},
//                    {label: '审核人', name: 'shy', width: 90, align: 'center'},
                    {label: '机构id', name: 'companyId', width: 1, align: 'right', hidden: true}
                ],
                dblclick: function (row) {
                    var pzid = $('#pzGrid').jfGridValue('id');

                    learun.layerForm({
                        id: 'preview_detail' + pzid,
                        title: '联查凭证',
                        url: config.webportal_server + 'pages/finance/pz/view.html?keyValue=' + pzid + '&companyId=' + companyId + 'ztId=701&access_token=' + config.getToken().access_token,
                        width: 1200,
                        height: 800,
                        maxmin: true,
                        btn: null
                    });
                },
                isPage: true,
                height: 500
            });

        },
        initData: function () {
            if (!!keyValue) {
              page.search();
            }
        },
        search: function (param) {
            param = param || {};
            param.companyId = companyId;
            param.kjnd = kjnd;
            param.kjkmCode = kjkmCode;
            param.wldxCode = wldxCode;

            page.refreshData(param);
        },
        refreshData: function (param) {
            learun.httpAsync('GET', config.base_server() + 'sourcepzs/findAll?modelId=' + keyValue + '&access_token=' + config.getToken().access_token, param, function (data) {
                $('.lr-layout-wrap').lrSetFormData(data);
                //$("#modelName").html(data.modelName);
                $('#pzGrid').jfGridSet('refreshdata', data);
            });
        }
    };

    page.init();
}
